package styledaco.servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

public class StyleServlet extends StyleDacoHttpServlet{
	/**
	 * 
	 */
	private static final long serialVersionUID = -1794310474021304132L;
	private Logger logger = Logger.getLogger(StyleServlet.class);
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		ArrayList<String> menus = getRequestUrlList(request);
		
		RequestDispatcher dispatcher = null;
		
		switch(menus.size()){			
			case 1:
				dispatcher = getServletConfig().getServletContext().getRequestDispatcher("/?m=Style");
				dispatcher.forward(request, response);
				break;
			case 2:
				//커뮤니티/Sub Menu
				dispatcher = getServletConfig().getServletContext().getRequestDispatcher("/?m=Style&s="+menus.get(1));
				dispatcher.forward(request, response);
				break;
			case 3:
				//커뮤니티/Sub Menu/Article_seq 
				dispatcher = getServletConfig().getServletContext().getRequestDispatcher("/?m=Style&s="+menus.get(1)+"&a="+menus.get(2));
				dispatcher.forward(request, response);
				break;
			default:
				logger.debug("응?");
		}
		
		logger.debug("Community Servlet Complete");
	}
}
